typedef (*command)();

int getpid(); void ps(); void chname(); void kmode(); void kswitch();
int wait(); void exit(); int fork(); void exec(); void help();
void upipe(); void pfd(); void close(); void read(); void write();

char		commandNames[14][10] = { "ps", "chname", "kmode", "kswitch", 
				"wait", "exit", "fork", "exec", "help", "pipe", "pfd",
				"close", "read", "write" };
command		commands[14] = { ps, chname, kmode, kswitch, wait, exit,
				fork, exec, help, upipe, pfd, close, read, write };

void main()
{
	int i = 0;
	char cmd[20];
	while (1)
	{
		printf("\n*****************************************************\n");
		printf("In the user space! My PID = %d", getpid());
		printf("\n*****************************************************\n");
		printf("Input Command: ");
		
		gets(cmd);
		
		printf("\n");
		for (i = 0; i < 14; ++i)
		{
			if (strcmp(commandNames[i], cmd) == 0)
			{
				(*commands[i])("");
				break;
			}
		}
	}
}
